#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    vector<long> dp(n + 1, 0);
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
        dp[i] = dp[i - 1] + a[i];
    }

    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }

    return 0;
}